using System;
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ClickNET;

public partial class suggest : ClickNET.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DBCmd dbc = new DBCmd();

        string keyword = Request["k"];
        if (keyword != null && keyword.Trim() != "")
        {
            string sql = "select * from img_info WHERE" +
                   " TITLE LIKE '%" + keyword.Trim().Replace("'", "''") + "%' OR FILENAME LIKE '%" + keyword.Trim().Replace("'", "''") + "%'";
            
            SQLiteConnection db = new SQLiteConnection(dbc.connectionString);
            DbCommand dbcmd = db.CreateCommand();
            SQLiteDataAdapter myad = new SQLiteDataAdapter(sql, db);

            ArrayList arrList = new ArrayList();
            DataSet ds = new DataSet();
            myad.Fill(ds, "img_info");

            foreach (DataRow row in ds.Tables["img_info"].Rows)
            {
                Response.Write("<a href=\"viewimage.aspx?id=" + row["id"].ToString() + "\"><div id=\"searchselect\"><div id=\"leftsearchpane\"><img src=\"galleries/" + row["folder"].ToString() + "/thumbs/tn_100_" + row["filename"].ToString() + "\" /></div><div id=\"rightsearchpane\"><span class=\"searchresulttitle\">" + row["title"].ToString() + "</span><br><br><span class=\"searchresultfilename\">");
                Response.Write(row["filename"].ToString() + " </span><br /><span class=\"searchresultdescription\">" + row["description"].ToString() + "</span><br></div></div></a>");
            }
        }
    }
}
